package cn.whale.kill.schedule;

import cn.whale.kill.domain.KillSessions;
import cn.whale.kill.service.IKillSessionsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;


    //秒杀定时任务
    @Component
    @Slf4j
    public class KillScheduleTask {

        @Autowired
        private IKillSessionsService killSessionsService;
        //定时上线秒杀任务，1天执行一次
        //上线最近2天的秒杀任务
        @Scheduled(cron = "0/10 * * * * *") //测试代码
        @Async  //异步执行
        public void publishKillSessions() throws InterruptedException {
            killSessionsService.publishLess3DayKillSessions();
        }
    }
